package main

import "fmt"

type Person2 struct {
	name string
	age int
}
type student struct {
	Person2
	school string
}
func (p Person2) eat(){
	fmt.Println("吃窝窝头．．．")
}

func (p Person2) getInfo()string  { //这个方法带返回值
	//Sprintf这个是带返回值的输出
	msg:=fmt.Sprintf("姓名:%s,年龄：%d",p.name,p.age)
	return msg
}

func (s student) getInfo()string  {
	msg:=fmt.Sprintf("姓名:%s,年龄：%d,学校：%s",s.name,s.age,s.school)
	return msg
}

func main()  {
	p1:=Person2{"王二狗",30}
	fmt.Println(p1.getInfo())
	s1:=student{Person2{"小王",18},"清华大学"}
	s1.eat() //吃窝窝头．．． 子类调用父类的方法


	//把父类的方法重写
	fmt.Println(s1.getInfo())
}
